package util

import (
	"math/rand"
	"time"

	"github.com/google/uuid"
)

// Charset 生成随机字符串
func Charset(length int) string {
	charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789."
	rand.NewSource(time.Now().UnixNano())
	b := make([]byte, length)
	for i := range b {
		b[i] = charset[rand.Intn(len(charset))]
		time.Sleep(50 * time.Millisecond)
	}
	return string(b)
}

// Uuid32 获取32位uuid
func Uuid32() string {

	uuidObj := uuid.New()
	uuidStr := uuidObj.String()
	uuid32 := ""
	for _, char := range uuidStr {
		if char != '-' {
			uuid32 += string(char)
		}
	}
	return uuid32
}
